<template xmlns="http://www.w3.org/1999/html">
  <sea-data-table ref="tableObject" url="/sys/org/page">
    <!--表头-->
    <sea-table-header slot="header">
      <!--标题栏-->
      <template slot="title">
        <sea-table-title title="组织结构配置" subtitle="">
          <sea-tips>
            <p>大型用户群体，例如：公司；</p>
            <p>一个机构包含多个用户组；</p>
            <p>业务上，用机构 ID 隔离数据。</p>
          </sea-tips>
        </sea-table-title>
      </template>

      <!--按钮栏-->
      <template slot="buttons">
        <el-button plain size="small" title="新增" icon="fa fa-plus" @click="onAction('new')"></el-button>
      </template>
    </sea-table-header>

    <!--表头-->
    <template slot="columns">
      <el-table-column property="organizationName" label="名称" width="180"></el-table-column>
      <el-table-column property="shortName" label="简称" width="180"></el-table-column>
      <el-table-column property="description" label="描述" width="180"></el-table-column>
      <el-table-column property="provinceName" label="省" width="180"></el-table-column>
      <el-table-column property="cityName" label="市" width="180"></el-table-column>
      <el-table-column property="countyName" label="县" width="180"></el-table-column>
      <el-table-column property="gmtCreate" label="创建日期" width="180"></el-table-column>
      <el-table-column property="gmtModified" label="修改日期" width="180"></el-table-column>

      <!--操作栏-->
      <sea-table-actionbar width="180" :on-action="onAction" :buttons="buttons"></sea-table-actionbar>
    </template>

    <!-- 弹窗、抽屉 -->
    <template slot="drawer">
      <organization-panel ref="panel"></organization-panel>
    </template>
  </sea-data-table>
</template>

<script>
import OrganizationPanel from "./panel";

export default {
    components: {
        OrganizationPanel
    },
    methods: {
        /**
         * 操作成功回调
         */
        onSucceed: function () {
            this.$refs.tableObject.reload();
        },
        /**
         * 操作栏事件分发
         * @param evt 事件
         * @param row 行级对象
         * @param old 可供回滚的参数
         */
        onAction: function (evt, row, old) {
            this.$refs.panel.onAction(evt, row, old);
        }
    },
    data() {
        return {
            // 操作栏
            buttons: [
                {type: 'btn', evt: 'edit', label: '编辑', title: '编辑当前行'}
                ,{type: 'btn', evt: 'remove', label: '删除', style: 'text-orange', title: '删除当前行'}
            ]
            // end--
        }
    }
}
</script>
